package J250405;

import java.io.*;
import java.util.Arrays;

public class IO2 {
    public static void main(String[] args) {
        try (Reader reader = new FileReader("./testDir/dir1/dir2/renameTo.txt")) {
            while (true) {
                char[] chars = new char[10];
                int n = reader.read(chars);
//                System.out.println("n = " + n);
                if (n == -1) {
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.print(chars[i]);
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        try (Writer writer = new FileWriter("./testDir/dir1/dir2/renameTo.txt",true)) {
            writer.write(" 你好世界我是writer");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
